<?php

/**
 * Trade filter form base class.
 *
 * @package    truetrader
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseTradeFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'trader_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Trader'), 'add_empty' => true)),
      'stock_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('StockExchange'), 'add_empty' => true)),
      'horizon_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TradeHorizon'), 'add_empty' => true)),
      'trade'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'entry'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'contract_number' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'support'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'resistance'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'objective'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'drop_out'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'description'     => new sfWidgetFormFilterInput(),
      'published_at'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'created_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'trader_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Trader'), 'column' => 'id')),
      'stock_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('StockExchange'), 'column' => 'isin')),
      'horizon_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('TradeHorizon'), 'column' => 'id')),
      'trade'           => new sfValidatorPass(array('required' => false)),
      'entry'           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'contract_number' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'support'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'resistance'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'objective'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'drop_out'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'description'     => new sfValidatorPass(array('required' => false)),
      'published_at'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'created_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('trade_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Trade';
  }

  public function getFields()
  {
    return array(
      'id'              => 'Number',
      'trader_id'       => 'ForeignKey',
      'stock_id'        => 'ForeignKey',
      'horizon_id'      => 'ForeignKey',
      'trade'           => 'Text',
      'entry'           => 'Number',
      'contract_number' => 'Number',
      'support'         => 'Number',
      'resistance'      => 'Number',
      'objective'       => 'Number',
      'drop_out'        => 'Number',
      'description'     => 'Text',
      'published_at'    => 'Date',
      'created_at'      => 'Date',
      'updated_at'      => 'Date',
    );
  }
}
